package cn.chuengxu.feignclient;

import cn.chuengxu.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    /**======================================================================================
    * @Title: create
    * @Description: 服务器异常,熔断返回的托底数据
    * @Author: Mr.Zhang
    * @Version: 1.0
    * @Date:  2022/7/28 20:00
    * @Parameters: [throwable]
    * @Return cn.chuengxu.feignclient.UserFeignClient
    ======================================================================================*/
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getUserById(Long id) {
                return User.builder().username("系统繁忙").build();
            }
        };
    }
}
